package org.vacoor.xqq.util;

/**
 * User: vacoor
 */
public abstract class OS {
    private static final boolean osIsWindows;
    private static final boolean osIsLinux;
    private static final boolean archIs32;
    private static final boolean archIs64;

    static {
        String os = System.getProperty("os.name", "").toLowerCase();
        osIsWindows = os.indexOf("windows") != -1;
        osIsLinux = os.indexOf("linux") != -1;

        String arch =  System.getProperty("os.arch", "").toLowerCase();
        archIs32 = -1 != arch.indexOf("x86") || -1 != arch.indexOf("i386") || -1 != arch.indexOf("i486") || -1 != arch.indexOf("i586") || -1 != arch.indexOf("i686");
        archIs64 = -1 != arch.indexOf("x64") || -1 != arch.indexOf("amd64");
    }

    private OS() {}

    public static boolean isWindows() {
        return osIsWindows;
    }

    public static boolean isLinux() {
        return osIsLinux;
    }

    public static boolean is32Arch() {
        return archIs32;
    }

    public static boolean is64Arch() {
        return archIs64;
    }

    public static void main(String[] args) {
        /*
        System.out.println(System.getProperty("os.name", " 1"));
        System.out.println(System.getProperty("os.arch", "x86"));
        System.out.println(System.getProperty("file.encoding", "UTF-8"));
        System.out.println(System.getProperty("java.version", "1"));
        System.out.println(System.getProperty("sun.arch.data.model", "32"));
        System.getProperties().list(System.out);
        */
        System.out.println(isWindows());
        System.out.println(is64Arch());
        System.out.println(System.getProperty("os.arch", "x86"));
    }
}
